Skip to content

HYPERFLEET-1019 - docs: add LeakTK secret scanning to pre-commit hooks#139

Open
ldornele wants to merge 3 commits into
openshift-hyperfleet:mainfrom
ldornele:HYPERFLEET-1019
Open

HYPERFLEET-1019 - docs: add LeakTK secret scanning to pre-commit hooks#139
ldornele wants to merge 3 commits into
openshift-hyperfleet:mainfrom
ldornele:HYPERFLEET-1019

Conversation

@ldornele
Copy link
Copy Markdown
Contributor

Summary

Adds comprehensive documentation for LeakTK secret scanning as the recommended replacement for rh-pre-commit in HyperFleet repositories. LeakTK is an open-source secret scanning toolkit developed by Red Hat's
InfoSec team that removes VPN requirements while maintaining the same Gitleaks-based detection with Red Hat-specific patterns.

Changes Made

Documentation Updates

  • Added LeakTK secret scanning hook section

    • Hook configuration table with leaktk.git.pre-commit details
    • Key features comparison (open-source, no VPN, Gitleaks-powered)
    • System requirements (Go 1.25+, btrfs-progs-devel)
  • Added migration guide: rh-pre-commit → LeakTK

    • Rationale for migration (VPN independence, open-source, enforceability)
    • Comparison table showing feature parity
    • Step-by-step migration instructions
    • Expected behavior and example output
  • Updated standard configuration

    • Added LeakTK repo to .pre-commit-config.yaml template
    • Placed secret scanning before code quality hooks
    • Updated prerequisites section with new dependencies
  • Added troubleshooting sections

    • Go version compatibility issues
    • btrfs-progs-devel installation
    • First-time compilation expectations (3-5 minutes)
  • Updated metadata

    • Last Updated: 2026-05-14

New References

Why This Change?

Benefits of LeakTK over rh-pre-commit

  1. No VPN requirement — works for all contributors (Red Hat associates and external)
  2. Open-source — MIT licensed, publicly accessible on GitHub
  3. Can be committed to repos — configuration lives in repository files, ensuring consistent enforcement
  4. Same security — uses Gitleaks engine with Red Hat-specific patterns (verified by InfoSec team)

Trade-offs

  • First-time compilation: 3-5 minutes on first commit (one-time cost, then cached)
  • System dependency: Requires btrfs-progs-devel for compilation

Migration Impact

Who is affected?

  • All HyperFleet contributors setting up pre-commit hooks
  • Existing developers who need to migrate from rh-pre-commit
  • CI/CD pipelines that use pre-commit hooks

Action Required

For new repositories: Use the updated .pre-commit-config.yaml template from this documentation.

For existing repositories using rh-pre-commit: Follow the migration guide in the "Secret Scanning Migration" section.

@openshift-ci openshift-ci Bot requested review from aredenba-rh and crizzo71 May 14, 2026 21:57
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 14, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign rafabene for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 220e8514-577a-4439-b21b-1456f4f635d1

📥 Commits

Reviewing files that changed from the base of the PR and between 971103c and 4328695.

📒 Files selected for processing (1)
  • hyperfleet/docs/pre-commit-hooks.md

📝 Walkthrough

Summary by CodeRabbit

  • Documentation
    • Added LeakTK-based secret scanning guidance and example pre-commit config pinned to v0.3.2
    • Documented new Secret Scanning Hook and noted initial LeakTK compilation/caching behavior on first run
    • Added migration guide for moving from the previous secret-scanning setup to LeakTK
    • Expanded prerequisites (Go 1.25+, optional btrfs tooling) and troubleshooting for compilation issues
    • Updated references with LeakTK links and related PR information

Walkthrough

This pull request updates the pre-commit hooks documentation to introduce LeakTK as the new secret scanning solution. The changes expand prerequisites to include Go 1.25+ and btrfs development headers, add a new "Secret Scanning Hook" section describing the LeakTK hook, include a LeakTK repository block in the standard .pre-commit-config.yaml example, document the expected compilation time on the first commit, provide a comprehensive migration guide for teams currently using rh-pre-commit, extend the troubleshooting section with LeakTK-specific issues, and update references with relevant LeakTK links.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding comprehensive LeakTK secret scanning documentation to the pre-commit hooks guide.
Description check ✅ Passed The description is well-organized and directly related to the changeset, clearly explaining what was added, why, and the migration path from rh-pre-commit to LeakTK.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@hyperfleet/docs/pre-commit-hooks.md`:
- Around line 316-323: Update the migration doc to include CI/CD steps so repos
continue enforcing hooks: explicitly instruct CI pipelines to install LeakTK
prerequisites (Go 1.25+ and btrfs-progs-devel), build the LeakTK/pre-commit
binary (same build used by developers) and cache it between jobs, replace
references to rh-pre-commit with the new built pre-commit binary invocation, and
add a CI step that runs the pre-commit binary (mirroring the developer `make
install-hooks` behavior) while noting the one-time compilation cost and how to
use pipeline cache to avoid it; reference the terms rh-pre-commit, LeakTK, make
install-hooks, and pre-commit in the doc so maintainers can locate and update
pipeline configs accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 2fef7d4f-54d0-423e-96e1-045f3c18332a

📥 Commits

Reviewing files that changed from the base of the PR and between f1ac5a4 and 74f5eec.

📒 Files selected for processing (1)
  • hyperfleet/docs/pre-commit-hooks.md

Comment thread hyperfleet/docs/pre-commit-hooks.md
Comment thread hyperfleet/docs/pre-commit-hooks.md Outdated
Comment on lines +290 to +294
Or via Homebrew on macOS:

```bash
brew install btrfs-progs
```
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Blocking

Category: Bug

brew install btrfs-progs doesn't exist on Homebrew — btrfs is a Linux-only filesystem (verified with brew search btrfs).

Per LeakTK's own build docs, btrfs-progs-devel is only needed when CGO_ENABLED=1. Setting CGO_ENABLED=0 removes the system dependency entirely and is the simplest path, especially for macOS.

Consider restructuring the prerequisite and migration sections to:

  1. Recommend CGO_ENABLED=0 as the default (no system deps needed, works on all platforms)
  2. Keep the btrfs-progs-devel / libbtrfs-dev instructions as a fallback for those who need CGO enabled
  3. Remove the macOS brew install btrfs-progs instruction entirely
# Example: if using pre-commit and CGO_ENABLED=1, install btrfs headers
# Fedora/RHEL: sudo dnf install btrfs-progs-devel
# Ubuntu/Debian: sudo apt install libbtrfs-dev
# macOS: set CGO_ENABLED=0 (no btrfs package available)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!


---

### Adding Pre-commit Hooks to a Repository
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

nit — non-blocking suggestion

Category: Inconsistency

This heading is at ### (h3) — the same level as the ### Step 1: through ### Step 7: below it, making them siblings instead of children. By contrast, the new ### Secret Scanning Migration section properly nests its children at #### (h4).

Consider changing the Step headings below to #### to nest them under this wrapper, matching the pattern used in the Secret Scanning Migration section.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
hyperfleet/docs/pre-commit-hooks.md (1)

353-383: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Add an explicit CI hook reinstallation step (make install-hooks).

Lines 353-383 update CI invocation and caching, but they still don’t explicitly tell CI to reinstall hooks via repo-standard make install-hooks. That leaves migration behavior inconsistent across repos that rely on Makefile wrappers.

Suggested doc patch
 **Step 5: Update CI/CD pipelines**

 If your repository enforces hooks in CI, update your pipeline configuration to use LeakTK instead of rh-pre-commit. The following steps apply regardless of CI platform (Prow, GitHub Actions, GitLab CI, etc.):

 1. **Ensure Go 1.25+ is available** in your CI environment
    - Verify with `go version` or install if needed

 2. **Install pre-commit framework**:
    ```bash
    pip install pre-commit
    ```
+
+3. **Reinstall hooks using the repo-standard target**:
+   ```bash
+   make install-hooks
+   ```

-3. **Cache the pre-commit environment** to avoid 3-5 minute LeakTK compilation on every run
+4. **Cache the pre-commit environment** to avoid 3-5 minute LeakTK compilation on every run
    - Cache directory: `~/.cache/pre-commit/`
    - Cache key: tie to `.pre-commit-config.yaml` content (e.g., hash of the file)
    - This reduces subsequent runs from minutes to seconds

-4. **Replace rh-pre-commit invocations** with pre-commit:
+5. **Replace rh-pre-commit invocations** with pre-commit:
    ```bash
    # Before (rh-pre-commit)
    rh-pre-commit run --all-files
    
    # After (pre-commit with LeakTK)
    pre-commit run --all-files
    ```

As per coding guidelines, "Migration from rh-pre-commit → LeakTK: replace the rh-pre-commit GitLab repo block with the LeakTK GitHub block, require developers/CI to reinstall hooks (make install-hooks) and ensure CI caches ~/.cache/pre-commit/ to avoid repeated compilation, then update CI invocation from rh-pre-commit run --all-files to pre-commit run --all-files."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@hyperfleet/docs/pre-commit-hooks.md` around lines 353 - 383, The doc update
misses an explicit CI hook reinstallation step; add a new numbered step after
installing pre-commit that instructs CI to run the repo-standard make target
"make install-hooks" (and renumber subsequent steps), and mention that CI should
hash or tie caching to ".pre-commit-config.yaml" and cache
"~/.cache/pre-commit/" so LeakTK (referenced by name) is compiled once; also
ensure the guidance replaces "rh-pre-commit" invocations with "pre-commit run
--all-files" and call out the Makefile wrapper ("make install-hooks") so repos
using that wrapper perform consistent hook installation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@hyperfleet/docs/pre-commit-hooks.md`:
- Around line 353-383: The doc update misses an explicit CI hook reinstallation
step; add a new numbered step after installing pre-commit that instructs CI to
run the repo-standard make target "make install-hooks" (and renumber subsequent
steps), and mention that CI should hash or tie caching to
".pre-commit-config.yaml" and cache "~/.cache/pre-commit/" so LeakTK (referenced
by name) is compiled once; also ensure the guidance replaces "rh-pre-commit"
invocations with "pre-commit run --all-files" and call out the Makefile wrapper
("make install-hooks") so repos using that wrapper perform consistent hook
installation.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: bff11411-e9dd-4ae1-bd88-c7a2cbd32faa

📥 Commits

Reviewing files that changed from the base of the PR and between 74f5eec and 971103c.

📒 Files selected for processing (1)
  • hyperfleet/docs/pre-commit-hooks.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants